package com.quiz.bis.controller;

import com.quiz.bis.domain.dto.*;
import com.quiz.bis.service.IQuestionDuplicateCheckService;
import com.quiz.common.core.controller.BaseController;
import com.quiz.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 题目查重控制器
 */
@RestController
@RequestMapping("/api/question/duplicate-check")
@Tag(name = "题目查重")
@RequiredArgsConstructor
public class QuestionDuplicateCheckController extends BaseController {

    private final IQuestionDuplicateCheckService duplicateCheckService;

    @Operation(summary = "提交题目")
    @PostMapping("/submit")
    public R<Long> submitQuestion(@RequestBody QuestionSubmitDto dto) {
        return duplicateCheckService.submitQuestion(dto);
    }

    @Operation(summary = "检查题目重复")
    @PostMapping("/check")
    public R<List<QuestionDuplicateResult>> checkDuplicate(@RequestBody QuestionDuplicateCheckDto dto) {
        return duplicateCheckService.checkDuplicate(dto);
    }

    @Operation(summary = "批量检查题目重复")
    @PostMapping("/batch-check")
    public R<List<QuestionDuplicateResult>> batchCheckDuplicate(@RequestBody List<QuestionDuplicateCheckDto> dtos) {
        return duplicateCheckService.batchCheckDuplicate(dtos);
    }

    @Operation(summary = "获取查重详细信息")
    @GetMapping("/detail")
    public R<QuestionDuplicateDetail> getDuplicateDetail(
            @RequestParam Long questionId,
            @RequestParam Long targetId) {
        return duplicateCheckService.getDuplicateDetail(questionId, targetId);
    }
}